/**
 * 严肃声明：
 * 开源版本请务必保留此注释头信息，若删除我方将保留所有法律责任追究！
 * 本软件已申请软件著作权，受国家版权局知识产权以及国家计算机软件著作权保护！
 * 可正常分享和学习源码，不得用于违法犯罪活动，违者必究！
 * Copyright (c) 2019-2021 十三 all rights reserved.
 * 版权所有，侵权必究！
 */
package ltd.newbee.mall;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import ltd.newbee.mall.config.ConfigYmlFileFactory;
import ltd.newbee.mall.config.annotation.EnableSecurity;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author 13
 * @qq交流群 796794009
 * @email 2449207463@qq.com
 * @link https://github.com/newbee-ltd
 */
@Slf4j
@MapperScan("ltd.newbee.mall.dao")
@SpringBootApplication
@EnableSecurity
@EnableAsync
@EnableTransactionManagement
@PropertySource(value = {"classpath:boot.yml"}, factory = ConfigYmlFileFactory.class)
public class NewBeeMallAPIApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(NewBeeMallAPIApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        path = StrUtil.isEmpty(path) ? "" : path;
        log.info("\n----------------------------------------------------------\n" +
                "Application NewBeeMall is running! Access URLs:\n" +
                "Local: \t\thttp://localhost:" + port + path + "/\n" +
                "External: \thttp://" + ip + ":" + port + path + "/\n" +
                "swagger-ui: \thttp://" + ip + ":" + port + path + "/swagger-ui/index.html\n" +
                "----------------------------------------------------------");
    }

}
